<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		<style type="text/css">
			.speak{
				/*输入框居中漂浮*/
			position: fixed;
			width:100%;
			top:50px;
			/*left:50%;*/
			margin: auto auto;
			padding: 0 5px;
			text-align: center;
			}
		</style>
	</head>
	<body>
		<script type="text/javascript">
			
			mui.init();
			window.addEventListener('refresh', function(e){//执行刷新
			  location.reload(); 
			  });
			
		</script>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">个人中心</h1>
		</header>
<!--		<div id="mengban"  style="left: 0;right:0;top:0;bottom:0;opacity:0.5;height:100%;text-align:center;color:#FAFAFA;position: fixed;background: #555555;z-index: 100; display: block;"><a href="../login.html"><h2 style="margin-top: 200px;">请先登陆</h2></a></div>-->
		<div class="mui-content">
			<ul class="mui-table-view" >
			    <li class="mui-table-view-cell mui-media" id="setting">
			        <a href="javascript:;">
			            <img id="headimg" class="mui-pull-left" style="width: 60px; height: 60px;" src="../../images/logo.png" onerror="this.onerror=null;this.src='../../images/logo.png'">
			            <div class="mui-media-body" style="margin-left: 100px;">
			                <div style="line-height:20px;"onclick="speak(this.getElementsByTagName('span')[0].id)"><span id='notename'></span><span class="mui-icon mui-icon-compose"></span><p>用户:<span id="username"></span></p><p  id="authenticate">未实名认证</p></div>
			            </div>
			        </a>
			    </li>
			    <li class="mui-table-view-cell  admin-li-span">
					<!--<a class="" href="#">-->
						备注电话：<span id='phone'>未设置</span><span class="mui-icon mui-icon-compose" onclick="speak('phone')"></span><span class="mui-btn mui-btn-yellow mui-icon mui-icon-phone" onclick="Phone(document.getElementById('phone').innerHTML)"></span>
					<!--</a>-->
					
				</li>
				<li class="mui-table-view-cell  admin-li-span" onclick="speak(this.getElementsByTagName('span')[0].id)">
					<!--<a class="" href="#">-->
						其他备注：<span id="note" >未设置</span><span class="mui-icon mui-icon-compose"></span>
					<!--</a>-->
					
				</li>
	 			<li class="mui-table-view-cell  admin-li-span"onclick="goto('news','user','list','')">
					<a class="mui-navigate-right" href="#">
						他的资讯<span class="mui-badge mui-badge-inverted">更多</span>
					</a>
					
				</li>
	<li id="news"></li>
 	
</ul>
<div id="speak" class="speak" style="display:none;background: #DDDDDD;">
			<p style="margin:auto auto;font-size: 1.2em;color:#EC971F">修改内容</p>
			<textarea id="contentnew" type="text"rows="1" cols="10"placeholder="请输入"></textarea>
			<div style="margin-top: -24px;border-radius:5px;">
			<input id="pubish" style="font-size: 18px;margin: 2px 5px;padding:0 10px;float: right;" value="确认" type="submit">
			<input  style="font-size: 18px;margin: 2px 5px;float: right;padding:0 10px;" value="取消" type="submit" onclick="javascript:(document.getElementById('speak').style.display='none')">
			</div>
		</div>
</div>
<script src="../../js/app.js"></script>
<script type="text/javascript">
   contentnew=document.getElementById('contentnew');
   //发布回复输入框控制
function speak(type){
	str=document.getElementById(type);
if(type=='note'){
	contentnew.rows=5;
contentnew.value=getFormatCodeb(str.innerHTML);	
//alert(str.innerHTML+'去空格'+getFormatCodeb(str.innerHTML));
}else{
	contentnew.rows=1;
contentnew.value=str.innerHTML;	
}
	document.getElementById('speak').style.display='block';//显示输入框
	var tid=tid||'';
		document.getElementById('pubish').onclick=function(){
			document.getElementById('speak').style.display='none';//隐藏发布按钮
			modify(type);
			}
}
function Phone(phone){
	 var btnArray = ['拨打', '取消'];  
                mui.confirm('是否拨打 ' + phone + ' ？', '提示', btnArray, function(e) {  
                    if (e.index == 0) {  
                        plus.device.dial(phone, false);  
                    }   
                });  

}
friendinfo();
var	p= 0;
function friendinfo(){//我的微博帖
			apptoken['act']= 'info';
			apptoken['tid']= tid;
			 mui.post(home.hos+'/friend/user',apptoken,function(data){
			 alert(data);
			var result=JSON.parse(data);
//			if(result.authenticate)
			switch(result.authenticate){
			case 1:
			  authenticate='<span class="mui-badge" style="background:#9AFF9A;color:#CD00CD">个人</span>';
			  break;
			case 2:
			  authenticate='<span class="mui-badge" style="background:#EEB422;color:#CD00CD">企业</span>';
			  break;
			default:
			  authenticate='<span class="mui-badge">未认证</span>';
			}
			if(result.notename=='0' && result.notename=='null' && result.notename=='undefined' && result.notename==''){
				result.notename='未设置';
			}
document.getElementById("notename").innerHTML=result.notename;
document.getElementById("note").innerHTML=result.note;
document.getElementById("phone").innerHTML=result.phone;
document.getElementById("username").innerHTML=result.username;
document.getElementById("authenticate").innerHTML=authenticate;
document.getElementById("headimg").src=home.uploads+'/img/user/'+result.headimg;
			},'text');
}
function modify(type){
//	alert(type+':'+contentnew.value);
	//k=键；act=修改方法，tid=主题id，type=修改类型；
	apptoken['k']= type||'';
	if(type=='note'){//如果修改的页面是内容多行文本，将会替换换行符
	apptoken['v']=getFormatCode(contentnew.value) ||'';
	}else{
		apptoken['v']=getFormatCodec(contentnew.value) ||'';
	}
	apptoken['tid']=tid;//获取详情id
	apptoken['act']='modify';//获取详情i
mui.post(home.hos+'/friend/admin',apptoken,function(data){
//	alert(JSON.stringify(data));
	if(isJSON(data)){//判断如果返回是json对象
		result=JSON.parse(data);//获取信息
		if(result.status==200){
		plus.ui.toast('修改成功');
	document.getElementById(type).innerHTML=apptoken['v'];	
		}else{
			alert('操作失败');
		}
	}else{
		alert('操作失败，服务器故障');
	}
})
}
//userinfo(){
//	apptoken['act']= 'info';
//			apptoken['tid']= tid;
//			 mui.post(home.hos+'/user/user',apptoken,function(data){
//			 alert(data);
//			var result=JSON.parse(data);
////			if(result.authenticate)
//			switch(result.authenticate){
//			case 1:
//			  authenticate='<span class="mui-badge" style="background:#9AFF9A;color:#CD00CD">个人</span>';
//			  break;
//			case 2:
//			  authenticate='<span class="mui-badge" style="background:#EEB422;color:#CD00CD">企业</span>';
//			  break;
//			default:
//			  authenticate='<span class="mui-badge">未认证</span>';
//			}
//			if(result.notename=='0' && result.notename=='null' && result.notename=='undefined' && result.notename==''){
//				result.notename='未设置';
//			}
//document.getElementById("notename").innerHTML=result.notename;
//document.getElementById("username").innerHTML=result.username;
//document.getElementById("authenticate").innerHTML=authenticate;
//document.getElementById("headimg").src=home.uploads+'/img/user/'+result.headimg;
//			},'text');
//}
news(0);
function news(num){//我的微博帖
				if(num==1){p=p+1}else{p=0;document.getElementById("news").innerHTML='';};
			apptoken['p']= p;
			apptoken['mid']= tid;
			apptoken['act']= 'userlist';
			 mui.post(home.hos+'/news/user',apptoken,function(data){
//			 alert(data);
			var result=JSON.parse(data);
			 var val='';
			 var pic='';
		for(var i=0;i<result.length;i++){
			if(result[i].pic===null || result[i].pic==='' || result[i].pic==='undefined'){
				pic='';
			}else{
			pd=result[i].pic.indexOf(",")==-1;//判断字符串里是否含有逗号如果不含有
			if(pd!=-1){
				var rpic=result[i].pic.split(",");
				pic='<img class="mui-media-object mui-pull-left" style="margin-right:10px" src="'+home.uploads+'/img/news/cut'+rpic[0]+'" onerror="this.onerror=null;this.src=\''+home.uploads+'/img/news/min'+rpic[0]+'\'" />';}
			}
			liststyle(result[i].id,getFormatCodec(result[i].content.substr(0,38)),result[i].refresh,pic,result[i].comment,result[i].collect,result[i].zan,result[i].relationoff);
			}
				//服务器返回响应，根据响应结果，分析是否登录成功；
			},'text');
}
function  liststyle(tid,contents,refreshtime,pic,comment,collect,zan,relationoff){
			var retime=new Date(parseInt(refreshtime) * 1000).format('yyyy-MM-dd hh:mm:ss');
	document.getElementById("news").innerHTML+='<div id="list'+tid+'" ><li class="mui-table-view-cell mui-media"><div class="mui-media-body" id="'+tid+'" onclick="goto(\'news\',\'home\',\'detail\','+tid+')" >'+pic+contents+'<p class="mui-ellipsis">'+retime+'</p></div></div></li>';
}
</script>
	</body>
</html>